<?php
//require_once('\Documents\Development\koncept\library\Koncept\Rest\Resource\Controller.php');
class User_ProfileController extends Koncept_Rest_Resource_Controller
{

    public function init()
    {
        $this->_helper->contextSwitch()
            ->addActionContext('get', array('xml', 'json'))
            ->addActionContext('post', array('xml', 'json'))
            ->addActionContext('put', array('xml', 'json'))
            ->addActionContext('delete', array('xml', 'json'))
            ->addActionContext('getEdit', array('xml', 'json'))
            ->addActionContext('index', array('xml', 'json'))
            ->setAutoJsonSerialization(true)
            ->initContext();
    }


    public function indexAction()
    {
        $this->view->users = User_Model_User::findAll();
    }

    public function getAction($id)
    {
        if($user = User_Model_User::findSingle($id)) {
            $this->view->pageTitle = 'User ' . $user->username;
            $this->view->user = $user;
        } else {
            $this->_notFound("User $id not found");
        }
    }

    public function postAction()
    {
        // action body
    }

    public function putAction()
    {
        // action body
    }

    public function deleteAction()
    {
        // action body
    }

    public function getEditAction($id)
    {
        if($user = User_Model_User::findSingle($id)) {
            $this->view->pageTitle = 'User ' . $user->username;
            $this->view->user = $user;
            $form = new User_Form_Profile;
            $form->setValues($user);
            $this->view->form = $form;
        } else {
            $this->_notFound("User $id not found");
        }
    }


}

